package net.oschina.app.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import net.oschina.app.R;
import net.oschina.app.bean.ActiveBean;
import net.oschina.app.util.CommonUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;
import uk.co.senab.photoview.PhotoView;

/**
 * Created by elf on 2017/1/18.
 */
public class DetailFriendsFragment extends Fragment {
    @BindView(R.id.iv_icont)
    CircleImageView mIvIcont;
    @BindView(R.id.tv_name)
    TextView mTvName;
    @BindView(R.id.tv_time)
    TextView mTvTime;
    @BindView(R.id.tv_des1)
    TextView mTvDes1;
    @BindView(R.id.tv_praisecount1)
    TextView mTvPraisecount1;
    @BindView(R.id.tv_commentcount1)
    TextView mTvCommentcount1;
    @BindView(R.id.tv_des2)
    TextView mTvDes2;
    @BindView(R.id.ll_likelist)
    LinearLayout mLlLikelist;
    @BindView(R.id.et_comment)
    EditText mEtComment;
    @BindView(R.id.iv_emoji)
    ImageView mIvEmoji;
    @BindView(R.id.iv_send)
    ImageView mIvSend;
    @BindView(R.id.iv_photo)
    PhotoView mIvPhoto;
    @BindView(R.id.gv_emoji)
    GridView mGvEmoji;
    private ActiveBean mActiveBean;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View itemView = LayoutInflater.from(CommonUtils.getContext()).inflate(R.layout.tweet_detail, container, false);
        ButterKnife.bind(this, itemView);
        Bundle arguments = getArguments();
        mActiveBean = (ActiveBean) arguments.get("bean");
        initData();
        return itemView;
    }

    private void initData() {
        Glide.with(CommonUtils.getContext()).load(mActiveBean.getPortrait()).into(mIvIcont);
        mTvName.setText(mActiveBean.getAuthor());
        mTvTime.setText(mActiveBean.getPubDate());
        mTvDes1.setText(mActiveBean.getMessage());
        mTvCommentcount1.setText(String.valueOf(mActiveBean.getCommentCount()));
        if (mActiveBean.getTweetimage() != null) {
            mIvPhoto.setVisibility(View.VISIBLE);
            Glide.with(CommonUtils.getContext()).load(mActiveBean.getTweetimage()).into(mIvPhoto);
        }else {
            mIvPhoto.setVisibility(View.GONE);
        }
    }

}
